package com.njwb.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

@Controller
@RequestMapping("test")
public class HelloController {

    @RequestMapping(value = "hello",headers = "content-type=application/json")
    public String hello(Model model){
        model.addAttribute("msg","您好，SpringMVC ~!!");
        return "hello";
    }

//    @RequestMapping(value = "hello",params = "username")
//    @RequestMapping(value = "hello",params = {"username=sa","password!=1234"})
//    public String hello(Model model){
//        model.addAttribute("msg","您好，SpringMVC ~!!");
//        return "hello";
//    }
//    @RequestMapping(value = "hello",method = RequestMethod.GET)
//    public String hello(Model model){
//        model.addAttribute("msg","您好，SpringMVC ~!!");
//        return "hello";
//    }

//    @RequestMapping(path = {"hello","world"})
//    public String hello(Model model){
//        model.addAttribute("msg","您好，SpringMVC ~!!");
//        return "hello";
//    }
//    @RequestMapping("hello")
//    public ModelAndView hello(){
//        ModelAndView modelAndView = new ModelAndView();
//        modelAndView.addObject("msg","您好，SpringMVC ~");
//        modelAndView.setViewName("hello");
//        return modelAndView;
//    }

//    @RequestMapping("hello")
//    public ModelAndView hello(ModelAndView modelAndView){
//        modelAndView.addObject("msg","您好，SpringMVC ~!");
//        modelAndView.setViewName("hello");
//        return modelAndView;
//    }

//    @RequestMapping("hello")
//    public String hello(Model model){
//        model.addAttribute("msg","您好，SpringMVC ~!!");
//        return "hello";
//    }

//    @RequestMapping("hello")
//    public String hello(ModelMap model){
//        model.addAttribute("msg","您好，SpringMVC ~!!!");
//        return "hello";
//    }

//    @RequestMapping("hello")
//    public String hello(Map modelMap){
//        modelMap.put("msg","您好，SpringMVC ~!!!!");
//        return "hello";
//    }

}
